package com.woniu.elderly.wares.controller;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import com.woniu.common.entity.Result;
import com.woniu.common.entity.WaresImg;
import com.woniu.elderly.wares.service.WaresImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.UUID;

/**
 * @Author: xuan
 * @Date: 2024/8/616:23
 * @Version: 1.0
 */
@RestController
@RequestMapping("/picture")
public class PictureController {
    @Autowired
    private WaresImgService imgService;
    @PostMapping("/")
    public Result<String> upload( MultipartFile file) {
        if (file == null) {
            throw new IllegalArgumentException("File cannot be null");
        }
        String path =  imgService.addpicture(file);
        return new Result<>(200, "success",path);
       }
}
